package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.common.ActivationStatus;
import com.ap.core.domain.MerchantDistributorDetailsId;
import com.ap.core.message.managertp.info.SubmitRTPMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.OriginalInfo;

/**
 * User: Ranjit.Singh
 * Check if provided Merchant is in Active Status
 */
public class RV0004Rule extends AbstractMerchantDistributorCheckRule<SubmitRTPMessageInfo, OriginalInfo> {

    @Override
    public boolean validate(MessageValidationInfo<SubmitRTPMessageInfo,OriginalInfo> infoObject) {
    	final SubmitRTPMessageInfo submitRTPMessageInfo = infoObject.getBoundObject();
        final String distributorIdentification = submitRTPMessageInfo.getRTPSenderInfo().getDistributorInfo().getDistributorId();       
        final MerchantDistributorDetailsId merchantDistributorDetailsId = new MerchantDistributorDetailsId(submitRTPMessageInfo.getRTPSenderInfo().getDetailMerchantInfo().getMerchantInfo().getMerchantId(), distributorIdentification);
        return isMerchantAssociatedWithDistributorInGivenState(merchantDistributorDetailsId, ActivationStatus.ACTIVE);
    }


}
